package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.admin.service.DistrictInfoService;
import com.atguigu.stgy.model.entity.CityInfo;
import com.atguigu.stgy.model.entity.DistrictInfo;
import com.atguigu.stgy.admin.service.impl.DistrictInfoServiceImpl;
import com.atguigu.stgy.model.result.R;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//

/**
 * (district_info)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/admin/region/district")
public class DistrictInfoController {
    /**
     * 服务对象
     */
    @Resource
    private DistrictInfoService districtInfoService;

    @Operation(summary = "查询市下所有的区")
    @GetMapping("/listByCityId")
    public R<List<DistrictInfo>> listByCityId(@RequestParam("id") Long cityId) {
        List<DistrictInfo> cityInfos = districtInfoService.list(Wrappers.lambdaQuery(DistrictInfo.class)
                .eq(DistrictInfo::getCityId, cityId));
        return R.ok(cityInfos);
    }

}
